package com.ibm.ops.parser;

import org.apache.log4j.Logger;

import com.ibm.ops.domain.OpsAuditLogMetaData;
import com.ibm.ops.exception.NoPropLogParserException;

public final class ParserFactory {
	
	private static Logger logger = Logger.getLogger(ParserFactory.class);

	public static final Parser createParserInstance(OpsAuditLogMetaData logMeta) throws NoPropLogParserException{
		Parser parser = null;
		logger.debug("create parser for " + logMeta.getType() + ".");
		switch(logMeta.getType()){
		case HUB:
			parser = new HubReportParser(null);
			break;
		case INFOSOURCE:
			parser = new InfosourceReportParser(null);
			break;
		case CIR:
			parser = new CIRReportParser(null);
			break;
		case FODS_REJECT:
			parser = new FODSRejectReportParser(null);
			break;
		case FODS_OUTOF_SEQUENCE:
		case FODS_NO_ORDER:
			parser = new FODSDoNotProcessReportParser(null);
			break;
		case FODS_EOD:
			parser = new FODSEodReportParser(null);
			break;
		case FOOT:
			break;
		default:
			throw new NoPropLogParserException("Can not create log parse for : " + logMeta.getType());
		}
		logger.debug("end create parser for " + logMeta.getType() + " " + parser);
		return parser;
	}
}
